<?php
include("../mysqlcon.php");
mysql_select_db($dbname,$conn);
mysql_query('SET NAMES utf8');
/* RECEIVE VALUE */
$validateValue=$_POST['validateValue'];
$validateId=$_POST['validateId'];
$validateError=$_POST['validateError'];


/* RETURN VALUE */
$arrayToJs = array();
$arrayToJs[0] = $validateId;
$arrayToJs[1] = $validateError;

/*ASK QUERY*/
$validatesql = "SELECT COUNT(*) as countu FROM `userlist` WHERE userlist_username = '$validateValue'";
$r = mysql_query($validatesql,$conn);
$rs = mysql_fetch_array($r);


if($validateId=="userlist_username"){
   if($rs[countu] != 1){		// validate??
   	$arrayToJs[2] = "true";			// RETURN TRUE
   	echo '{"jsonValidateReturn":'.json_encode($arrayToJs).'}';			// RETURN ARRAY WITH success
   }else{
   			$arrayToJs[2] = "false";
   			echo '{"jsonValidateReturn":'.json_encode($arrayToJs).'}';		// RETURN ARRAY WITH ERROR	
   }  
}


?>